package com.ticket.controller;

import com.ticket.entity.User;
import com.ticket.service.UserService;
import com.ticket.service.impl.UserServiceImpl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;

/**
 * @author 全谢民
 * @version 8.0
 * @description: TODO   用户个人信息
 * @date 2023/10/16 10:20
 */
public class UserPersonalController {
    UserService us = new UserServiceImpl();

    /*
     * @author 全谢民
     * @description TODO 用户查看个人信息
     * @date 2023/10/16 14:05
     */
    public Object selUserPersona(HttpServletRequest request , HttpServletResponse response){
        int userId = Integer.parseInt(request.getParameter("userId"));
        User user = new User(userId);
        user = us.selUser(user);
        request.setAttribute("user",user);
        return "forward:/user_page/userProfile.jsp";
    }
    //用户修改个人信息
    public Object updUserPersona(HttpServletRequest request , HttpServletResponse response){
        int userId = Integer.parseInt(request.getParameter("userId"));
        String userHeader = request.getParameter("file");
        String userName = request.getParameter("nickName");
        int gender = Integer.parseInt(request.getParameter("gender"));
        String birth = request.getParameter("birth");
        String interest = request.getParameter("interest");
//        int userId, String userName, int sex, LocalDate birth, String interest, String userHeader
//        User user = new User(userId,userName,gender,birth,interest,userHeader);
        User user = new User(userId);
        int count = us.updUser(user);
        return null;
    }
}
